//
//  ViewIncomeViewController.m
//  Wallets Manager
//
//  Created by Tung Nguyen on 10/21/12.
//  Copyright (c) 2012 BKHN. All rights reserved.
//

#import "ViewIncomeViewController.h"

@interface ViewIncomeViewController ()

@end

@implementation ViewIncomeViewController
@synthesize incomeNameTextField;
@synthesize categoryImageView;
@synthesize categoryTextField;
@synthesize amountTextField;
@synthesize dateTextField;
@synthesize walletTextField;
@synthesize planImageView;
@synthesize planTextField;
@synthesize noteTextField;
@synthesize currentIncome;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    folyAppDelegate *delegate = [[UIApplication sharedApplication]delegate];
    
    incomeNameTextField.text = currentIncome.i_name;
    categoryTextField.text = currentIncome.iToIncomeType.it_name;
    [categoryImageView setImage:[UIImage imageNamed:currentIncome.iToIncomeType.it_image]];
    amountTextField.text = [NSString stringWithFormat:@"%d",[currentIncome.i_amount integerValue]];
    
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init];
    [dateFormatter setDateFormat:@"MM/dd/yyyy"];
    dateTextField.text = [dateFormatter stringFromDate:currentIncome.i_date];
        
    walletTextField.text = delegate.currentWallet.w_name;
    planTextField.text = currentIncome.iToPlan.p_name;
    [planImageView setImage:[UIImage imageNamed:currentIncome.iToPlan.p_image]];

    noteTextField.text = currentIncome.i_notes;
    // Do any additional setup after loading the view from its nib.
}

- (void)viewDidUnload
{
    [self setIncomeNameTextField:nil];
    [self setCategoryImageView:nil];
    [self setCategoryTextField:nil];
    [self setAmountTextField:nil];
    [self setDateTextField:nil];
    [self setWalletTextField:nil];
    [self setNoteTextField:nil];
    [self setPlanImageView:nil];
    [self setPlanTextField:nil];
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

- (IBAction)backButtonPressed:(id)sender {
    [self.navigationController popViewControllerAnimated:YES];
}
@end
